/**
 * OverView: 程序主入口
 * Author: Zhaomi
 * Date: 13-4-17 下午8:36
 * Email: 852632338@qq.com
 * Create By JetBrains WebStorm.
 */
/**
 * 下面为多个页面应用 共用 基础库定义
 * */
require("../libs/plugins/zepto.js");
require("../libs/casebox/tpl-extend.js");
require("../libs/network/mvr.js");
require("../libs/base-conf.js");
require("../libs/ui/load-frame.js");
require("../libs/gamepump/xdata.js");
require("../libs/utils/convert.js");
require("../libs/utils/stat.js");

var NativeApp = require("../libs/phonegap/native-bridge.js");
var Url = require("../libs/utils/url.js");
var Imports = require("../libs/utils/imports.js");
var AppContext = require("../libs/casebox/app-context.js");
var Cfg = require("../libs/base-conf.js");
var Slip = require("../libs/ui/slip.js");
var global = window;

var height = AppContext.REAL_SCREEN_HEIGHT - 82 + "px"; //window.innerHeight - 82 + "px";
$('.dt-maximum').css('height', height);
var titleImg = $('#title-img');

//全局变量,供各个页面在加载数据后refresh用.
var dtcontent = $("#dt-content").get(0);
window.slipjs = Slip('px', dtcontent, {no_bar: true,perfect:true,bar_css:"opacity:0;"});
//alert(slipjs.isContentOverFlow());
/**
 * 如果是手机模式下，则将XHR重写
 * */
if(global.IS_MOBILE_MODE){
    $.ajaxSettings.xhr = function(){
        return new NativeApp.CrossHttpRequest();
    };
}

NativeApp.switchConsoleLog(Cfg.debugMode);
console.log("=====Debug:" + Cfg.debugMode + "====");

var pager = Url.getUrlVal("pager");

switch (pager){ 
    case "album":
        titleImg.attr('src', '../images/zt.png');
        require("../libs/plugins/zepto-touch.js");
        Imports("../page-builder/album.js").run();
        break;      
    case "article":
        Imports("../page-builder/article.js").run();
        break;      
    case "card":
        titleImg.attr('src', '../images/kp.png');
        require("../libs/plugins/zepto-touch.js");
        Imports("../page-builder/card.js").run();
        break;      
    case "guide":
        titleImg.attr('src', '../images/gl.png');
        require("../libs/plugins/zepto-touch.js");
        Imports("../page-builder/guide.js").run();
        break;    
    case "index":
        titleImg.attr('src', '../images/tj.png');
        require("../libs/plugins/zepto-touch.js");
        Imports("../page-builder/index.js").run();
        break;
    default :
        console.error("pager[" + pager + "] error");
        break;
}

console.log('Start loading: ', pager);